Repository navigation
Conversation
…ut event Same label rules as Omarchy 4.5's KeyboardLayoutModel.js; hyprctl devices only at start and on configreloaded, squeekboard's events ignored.
…ected later Hyprland has no device-added event, so a keyboard plugged in after the bar started never got a label. A layout event from a typed keyboard the last read didn't have now starts one more hyprctl read.
derekross
left a comment
There was a problem hiding this comment.
Thank you, Lef. This is the split I asked for, and the rework is the one I hoped for: the layout comes from the event, hyprctl runs only at start, after a reload and for a keyboard it hasn't seen, and the labels are xkb's briefs like Omarchy's own widget. I compared your functions with KeyboardLayoutModel.js in the 4.5.0-3 package and the label rules match. CI is green.
Two things I'd change before you take it to the phone, so the run tests the final shape:
-
Which devices count as a keyboard. Hyprland lists the phone's own key devices as keyboards too, each carrying the seat's layout list. You exclude
gpio-keysby name; I don't know that the power key and the other input nodes on our phones all go by names in your list, and if one doesn't, a phone with two layouts set and no keyboard attached shows the label all the time. Could you posthyprctl -j devices | jq -r '.keyboards[] | "\(.name) \(.layout)"'from the 8 Pro with no keyboard connected? I'll read the same on my 7 Pro. Your #866 already decides "a real keyboard is connected" by bus and key capabilities; I'd like the two to agree. -
The label when the keyboard goes away. Nothing re-reads the devices on a disconnect, so after a Bluetooth keyboard drops the count stays above one and the label stays until the shell restarts. A slow re-read only while the label is showing would be enough.
Smaller: a devices read that started before a switch can finish after it and put the old layout back; and Omarchy's widget takes the event's fields with event.parse(2) where it exists, which is worth copying since a layout's description can contain a comma.
Your own list of what hasn't run is the right one (the event's fields on Quickshell, the names on Hyprland 0.57, whether a new keyboard sends activelayout, xkbcli on the image, the event count while typing on the on-screen keyboard). With those, uname -r, pacman -Q omarchy quickshell hyprland omamobile-shell, a tools/phone-smoke report and a screenshot of the bar with a call up, I'll look again. I set the number when it merges.
… shows Which keyboards count now follows derekross#866's rule: a new omamobile-keyboards lists the input devices udev marks as keyboards on Bluetooth or real USB with the letter keys and space, and only Hyprland keyboards with those names count. The 8 Pro with nothing attached lists gpio-keys and squeekboard, both us,gr; neither counts. While the label shows, the devices are read again every 10 s, so it goes away when a keyboard disconnects. A read that started before a switch no longer puts the old layout back, and the event's fields come from event.parse(2) where Quickshell has it (a description can hold a comma).
… newline, -N suffix)
|
@derekross fixed, all four. How:
Two smaller things are still open and I'll do them next: the event path still only looks at the name list, and a missing |
…ile-keyboards fails A switch event now sets the label only for a keyboard the last devices read found real (derekross#866's bus/key rule), not by the name list alone, so a phone key device the list misses can't set it. An event from a device the last read hasn't seen at all still starts a read. When omamobile-keyboards is missing or fails, no keyboard counts (the phone's own keys must never show the label) and the bar logs why, once.
|
@derekross the two smaller things I said I'd do next are in be0939f. How:
Tests for the model side of both in |
derekross
left a comment
There was a problem hiding this comment.
Thank you, Lef, for working through all four so carefully. Counting only the keyboards that pass #866's rule, matched by Hyprland's own spelling of the names, answers the first one properly, and with your 8 Pro list (gpio-keys and squeekboard only) I'm reassured; I'll read the same list on my 7 Pro with nothing attached and post it here. The slow re-read while the label shows, the switch counter that keeps an older read from winning, and event.parse(2) are all as I'd hoped.
One question I want to settle before this leaves draft, and it's mine as much as yours: omamobile-keyboards and the Python in #866's lock.sh are now the same rule written twice. If one changes, the bar and the lock page will disagree about whether a keyboard is connected. I'd rather have one copy: either #866 calls the shell's omamobile-keyboards, or a test keeps the two equal. I'll say which on #866 too, so you don't have to choose alone.
The rest is the phone run in your list. Two small things for it: top once while the label is showing, since the bar then reads the devices every 10 s, and the version, which the branch doesn't bump yet; I'll set the number and push it at merge. Heads-up: #1010 and #1014 both add to the end of StatusModel.js and its test, so whichever of you lands later will need a small rebase that keeps both sets of functions.
|
Decision on keyboard detection: one writer, the Settings package (#866). The shell only reads what Settings decided, so please drop the second copy in |
|
Thanks @derekross, understood: one writer, #866 (#866). How I'd do it, tell me if this is what you mean by shared state. The rule ( The other way would be a read-only command in Settings that the bar calls. That's one copy of the code but not one writer, so I'd go with the file unless you'd rather have the command. Either way it touches #866, and you're about to run #866 on your 7 Pro. I don't want to move its head under that run, so I'll do the #866 part once your run is done (or now, if you'd rather run the final shape). This PR then follows on top. Nothing pushed for this yet. |
derekross
left a comment
There was a problem hiding this comment.
Thank you, Lef. Yes: a small state file that Settings writes and the bar only reads is what I meant by shared state, and "no file means no keyboard" keeps the phone's own keys from ever showing the label.
Three things to build in. A udev-started user unit runs when a keyboard appears, not when it goes, so the file also needs rewriting on removal, or the label outlives the keyboard again. Write it to a temporary name and rename it, so the bar never reads half a file. On the order, I lean towards leaving #866 as it is while my run of it is pending, and putting the writer in its own small pull request on top of #866, with this one following it; that keeps my run valid and gives the writer its own review. I'll confirm here.
I still owe you the 7 Pro's device list with nothing attached; I'll post it with my #866 run.
@derekross part (b) of the split of #892: the keyboard layout label in the bar, beside the clock. It only shows while the hardware keyboard has more than one layout, so with one layout the bar looks like before.
I looked at Omarchy 4.5's
KeyboardLayoutModel.jslike you suggested. The label now comes from theactivelayoutevent itself (keyboard name and description) with the same brief rules, so a switch doesn't starthyprctlat all, and events from squeekboard's virtual keyboard are ignored.hyprctl -j devicesruns at start, after a config reload, and when a layout event comes from a keyboard it hasn't read yet, so a keyboard connected later gets its label too.xkbcli listruns once, when a label is first needed. Labels follow Omarchy's briefs now instead of my old rule, Greek is still GR and English EN.It doesn't depend on (a) or (c), the three can merge in any order. Tests are in
test/status-model.js.I haven't put a version bump in, you said you set the shell's number when each part merges.
Tested on my desktop: test/all for omamobile-shell and tools/pr-check origin/main. Not run on the phone. That also means I don't know yet that Quickshell hands over
event.datathe way the code expects, that the event names are right on Hyprland 0.57, that a newly connected keyboard sends anactivelayoutwhen it appears, or thatxkbcliis on the phone image (on my desktop it comes with libxkbcommon). I also haven't counted the events while typing on the on-screen keyboard, which you asked for. All of that comes from the 8 Pro next, with uname, pacman and a phone-smoke report added here before I ask for a merge. Please treat it as a draft until then.